package cz.muni.fi.pa165.library.backend;

import java.io.Serializable;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import javax.validation.constraints.NotNull;

/**
 * This entity represents a reader. It's attributes are first name, surname,
 * birth number, address, email and telephone number (the last is not required).
 *
 * @author Matúš Abaffy
 */
@Entity
@Table(uniqueConstraints = {
    @UniqueConstraint(columnNames = "birthnumber"),
    @UniqueConstraint(columnNames = "email")})
public class Reader implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    @NotNull
    private String firstName;
    @NotNull
    private String surname;
    @NotNull
    private String birthNumber;
    @NotNull
    private String address;
    @NotNull
    private String email;
    
    private String password;
    private String telephoneNumber;

    public Reader() {
    }

    public Reader(String firstName, String surname, String birthNumber, String address, String email, String telephoneNumber, String password) {
        this.firstName = firstName;
        this.surname = surname;
        this.birthNumber = birthNumber;
        this.address = address;
        this.email = email;
        this.telephoneNumber = telephoneNumber;
        this.password = password;
    }

    public Long getId() {
        return id;
    }
     public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }


    public void setId(Long id) {
        this.id = id;
    }

    public String getFirstName() {
        return firstName;
    }

    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

    public String getSurname() {
        return surname;
    }

    public void setSurname(String surname) {
        this.surname = surname;
    }

    public String getBirthNumber() {
        return birthNumber;
    }

    public void setBirthNumber(String birthNumber) {
        this.birthNumber = birthNumber;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getTelephoneNumber() {
        return telephoneNumber;
    }

    public void setTelephoneNumber(String telephoneNumber) {
        this.telephoneNumber = telephoneNumber;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        if (!(object instanceof Reader)) {
            return false;
        }
        Reader other = (Reader) object;
        if ((this.id == null) || (this.id != null && !this.id.equals(other.getId()))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "id=" + id + ", name: " + firstName + " " + surname;
    }
}
